<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">


    /* switch 和 if 是可以转换*/
    var type = 'add'; // sub
    var n1 = 12;
    var n2 = 34;
    var rs;

    if( type == 'add' ){
        // 字符串除了之前判断长度，== 判断字符串的字符是否都一样
        rs = n1 + n2;
    }else if( type == 'sub'){
        rs = n1 - n2;
    }else{
        rs = n1 * n2;
    }

    console.log(rs);


</script>

</html>
